local shensu = fk.CreateSkill {
  name = "mini_ex__shensu",
}

Fk:loadTranslationTable{
  ["mini_ex__shensu"] = "神速",
  [":mini_ex__shensu"] = "你可以：跳过判定阶段和摸牌阶段；<br>跳过出牌阶段；<br>跳过弃牌阶段并失去1点体力；<br>"..
  "你每选择一项，视为使用一张无距离限制且无视防具的【杀】。",

  ["#mini_ex__shensu1-choose"] = "神速：跳过判定阶段和摸牌阶段，视为使用无距离限制、无视防具的【杀】",
  ["#mini_ex__shensu2-choose"] = "神速：跳过出牌阶段，视为使用无距离限制、无视防具的【杀】",
  ["#mini_ex__shensu3-choose"] = "神速：跳过弃牌阶段并失去1点体力，视为使用无距离限制、无视防具的【杀】",

  ["$mini_ex__shensu1"] = "吾等无需恋战。",
  ["$mini_ex__shensu2"] = "吾自当以一当十，速战速决！",
}

shensu:addEffect(fk.EventPhaseChanging, {
  anim_type = "offensive",
  can_trigger = function(self, event, target, player, data)
    return target == player and player:hasSkill(shensu.name) and
      not player:prohibitUse(Fk:cloneCard("slash")) and not data.skipped and
      ((data.phase == Player.Judge and player:canSkip(Player.Draw)) or data.phase == Player.Play or data.phase == Player.Discard)
  end,
  on_cost = function(self, event, target, player, data)
    local room = player.room
    local prompt = "#mini_ex__shensu1-choose"
    if data.phase == Player.Play then
      prompt = "#mini_ex__shensu2-choose"
    elseif data.phase == Player.Discard then
      prompt = "#mini_ex__shensu3-choose"
    end
    local use = room:askToUseVirtualCard(player, {
      name = "slash",
      prompt = prompt,
      skill_name = shensu.name,
      extra_data = {
        bypass_distances = true,
        bypass_times = true,
        extraUse = true,
      },
      skip = true,
    })
    if use then
      event:setCostData(self, {extra_data = use})
      return true
    end
  end,
  on_use = function(self, event, target, player, data)
    local room = player.room
    data.skipped = true
    if data.phase == Player.Judge then
      player:skip(Player.Draw)
    elseif data.phase == Player.Discard then
      room:loseHp(player, 1, shensu.name)
    end
    room:useCard(event:getCostData(self).extra_data)
  end,
})

shensu:addEffect(fk.TargetSpecified, {
  can_refresh = function(self, event, target, player, data)
    return table.contains(data.card.skillNames, shensu.name) and data.to:isAlive()
  end,
  on_refresh = function(self, event, target, player, data)
    data.to:addQinggangTag(data)
  end,
})

return shensu
